package bcxd.firstline.focalcompany.machining;

import java.sql.Connection;
import java.util.Map;

import jt.classic.system.context.ISystemContext;
import jt.classic.system.user.IUser;

import org.limp.basework.MachiningException;
import org.limp.basework.SimpleBean;
import org.limp.basework.SimpleBean4Table;
import org.limp.basework.SimpleBeanMachining;
import org.limp.basework.Table;
import org.limp.basework.impl.CommonBean4HSQ;
import org.limp.basework.impl.SimpleBean4TableImpl;
import org.limp.basework.tools.BaseworkUtil;
import org.limp.mine.DataTrimmerI;
import org.limp.mine.DateTrimmer;
import org.limp.mine.EncryptTool;
import org.limp.mine.RandomUtil;
import org.limp.mine.StringTool;

/**
 * 核心企业订单支付数据加工
 * 
 * @author mido
 * 
 */
public class FocalCompanyPaymentMachining implements SimpleBeanMachining {
	/**
	 * 
	 */
	public SimpleBean machining(SimpleBean arg0, Table arg1,
			CommonBean4HSQ arg2, Connection arg3, int arg4)
			throws MachiningException {
		if (arg4 == -4) {
			if (ISystemContext.invalidSesstion(arg2.getRequest())) {
				throw new MachiningException("invalid session.");
			}
			// 更新会话用户对象信息
			IUser user = ISystemContext.getSessionUser(arg2.getRequest());
			arg0.getResource().put("PM_TIME", DateTrimmer.getYMDHMS());
			arg0.getResource().put("PM_USERID", user.id());
			arg0.getResource().put("PM_USERNAME", user.iname());
		} else if (arg4 == 3) {
			SimpleBean4Table sbt = new SimpleBean4TableImpl("fcindent");
			sbt.getResource().put("idstatus", "1");
			sbt.getResource().put("idpaystatus", "1");
			sbt.getResource().put("idid", arg0.getResource().get("PM_IDID"));

			BaseworkUtil basework = new BaseworkUtil();
			try {
				basework.manualUpdate1(sbt, arg3);
			} catch (Exception ex) {
				throw new MachiningException("focalCompany payment error.", ex);
			}
		}
		return null;
	}
}
